using System;
using System.Collections.Generic;
using UnityEngine;

[Serializable]
public class material_class
{
	public bool active;

	public bool foldout;

	public List<Material> material;

	public List<int> combine_count;

	public List<GameObject> combine_parent;

	public value_class material_value;

	public material_class()
	{
		material = new List<Material>();
		combine_count = new List<int>();
		combine_parent = new List<GameObject>();
		material_value = new value_class();
		add_material(0);
	}

	public int set_material(GameObject @object, int material_number)
	{
		MeshRenderer meshRenderer = (MeshRenderer)@object.GetComponent(typeof(MeshRenderer));
		float time = UnityEngine.Random.Range(0f, 1f);
		material_number = Mathf.FloorToInt(material_value.curve.Evaluate(time) * (float)material.Count);
		if (material_number > material.Count - 1)
		{
			material_number = material.Count - 1;
		}
		int result;
		if ((bool)material[material_number])
		{
			if ((bool)meshRenderer)
			{
				if (meshRenderer.sharedMaterials.Length == 0)
				{
					result = 0;
				}
				else
				{
					meshRenderer.sharedMaterial = material[material_number];
					result = material_number;
				}
			}
			else
			{
				result = 0;
			}
		}
		else
		{
			result = 0;
		}
		return result;
	}

	public void add_material(int index)
	{
		Material item = null;
		GameObject item2 = null;
		material.Insert(index, item);
		material_value.add_value(index, 50f);
		combine_count.Insert(index, 0);
		combine_parent.Insert(index, item2);
	}

	public void erase_material(int index)
	{
		if (material.Count > 0)
		{
			material.RemoveAt(index);
			material_value.erase_value(index);
			combine_count.RemoveAt(index);
			combine_parent.RemoveAt(index);
		}
	}

	public void clear_material()
	{
		material.Clear();
		material_value.clear_value();
		combine_count.Clear();
		combine_parent.Clear();
	}
}
